(function () {
    "use strict";

    var animals = [{
        specie: 'насекомо',
        race: 'светулка',
        legs: 8
    }, {
        specie: 'риба',
        race: 'делфин',
        legs: 0
    }, {
        specie: 'насекомо',
        race: 'пчела',
        legs: 6
    }, {
        specie: 'риба',
        race: 'кит',
        legs: 0
    }, {
        specie: 'птица',
        race: 'щъркел',
        legs: 2
    }];

    var groupedResult =
        _.chain(animals)
            .groupBy('specie')
            .value();

    console.log(groupedResult);

    var result =
        _.chain(groupedResult)
            .map(function (group) {
                return _.sortBy(group, 'legs')
            })
            .value();

    console.log(result);
}());